﻿using PureMVC.Interfaces;

namespace SMS.Customer
{
    /// <summary>
    /// Provides a way for the module to communicate with the rest of the
    /// application through a facade.
    /// </summary>
    public class ModuleFacadeAdapter
    {
        #region Members

        /// <summary>
        /// Singleton instance.
        /// </summary>
        private static ModuleFacadeAdapter m_instance;
        /// <summary>
        /// Thread-safe lock.
        /// </summary>
        private static readonly object m_staticSyncRoot = new object();
        /// <summary>
        /// The facade this module adapts to.
        /// </summary>
        private static IFacade m_facade;
        /// <summary>
        /// Gets or sets the facade this module adapts to.
        /// </summary>

        #endregion

        #region Properties

        public IFacade Facade
        {
            get { return m_facade; }
            set { m_facade = value; }
        }

        public static ModuleFacadeAdapter Instance
        {
            get
            {
                if (m_instance == null)
                {
                    lock (m_staticSyncRoot)
                    {
                        if (m_instance == null)
                            m_instance = new ModuleFacadeAdapter();
                    }
                }
                return m_instance;
            }
        }

        #endregion
    }
}